package com.dada.domain.common;

import org.jooq.Condition;

import java.util.List;

import static org.jooq.impl.DSL.trueCondition;

public interface Conditional {
    /**
     * 获取查询条件
     */
    List<Condition> conditions();

    /**
     * 合并查询条件
     */
    default Condition toCondition() {
        return conditions().stream().reduce(Condition::and).orElse(trueCondition());
    }
}